package cc.geguo.user;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 作者  Administrator
 * 时间  2017/3/15 20:56
 * 文件  AjaxDemo40
 * 描述
 */
@WebServlet(name = "AjaxSelectServlet",urlPatterns = "/select")
public class AjaxSelectServlet extends HttpServlet {
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");// 传入的是u8 流
		String province = request.getParameter("province");
		response.setContentType("text/xml;charset=utf-8");
		//获取字符输出流
		PrintWriter pw = response.getWriter();

		pw.write("<?xml version='1.0' encoding='UTF-8'?>");
		pw.write("<root>");
		if("广东".equals(province)){
			pw.write("<city>广州</city>");
			pw.write("<city>深圳</city>");
			pw.write("<city>中山</city>");

		}else if("湖南".equals(province)){
			pw.write("<city>长沙</city>");
			pw.write("<city>株洲</city>");
			pw.write("<city>湘潭</city>");
			pw.write("<city>岳阳</city>");
		}

		pw.write("</root>");
		pw.flush();
		pw.close();
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

	}
}
